<!--
 * @Date: 2023-01-10 10:45:01
 * @LastEditTime: 2023-03-10 17:51:42
 * @FilePath: /hash-guess-game/src/App.vue
 * 介绍:
-->
<script setup lang="ts">
import PageView from "@@/layout/PageView.vue";
import { vantThemeVars } from "@@/hooks/init";
import useSysStore from "@@/store/useSysStore";
import useBalanceStore from "@@/store/useBalanceStore";
import pubSub from "pubsub-js";
import changeLang from "./hooks/changeLang";

const sysStore = useSysStore();
const balanceStore = useBalanceStore();

changeLang(sysStore.setting.language);
/**初始化sys系统 */
async function initSys(): Promise<boolean | never> {
  const res = await sysStore.login();
  if (!res) {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve(initSys());
      }, 5000);
    });
  }
  onLogined();
  return true;
}
initSys();
function onLogined() {
  balanceStore.getCoinList();
  pubSub.publish("onLogined");
}
</script>

<template>
  <!-- vant 全局配置 -->
  <van-config-provider theme="dark" :theme-vars="vantThemeVars">
    <PageView />
  </van-config-provider>
</template>

<style lang="less">
@import url(@@/common/css/common.less);
@import url(@@/common/css/effects.less);
@import url(@@/common/css/layout.less);
@import url(@@/common/css/transition.less);
@import url(@@/common/css/text.less);
@import url(@@/common/css/color.less);
@import url(@@/common/css/init.css);
@import url(@@/common/css/var.css);
//vant 全局变量
@import url(@@/common/css/vant-reset.less);
</style>
